//
//  WmcRecognitionListCell.swift
//  YPWatermarkCamera
//
//  Created by 周诗松 on 2022/10/18.
//

import UIKit

class WmcRecognitionListCell: WmcBaseCollectionCell {
    
    override func makeUI() {
        contentView.layer.borderWidth = 2
        contentView.layer.cornerRadius = 5
        
        contentView.addSubview(imgView)
        contentView.addSubview(textLabel)
        
        imgView.snp.makeConstraints { make in
            make.top.left.equalTo(6)
            make.right.equalTo(-6)
            make.bottom.equalTo(-40)
        }
        
        textLabel.snp.makeConstraints { make in
            make.bottom.equalTo(-10)
            make.left.right.equalToSuperview()
            make.height.equalTo(20)
        }
    }
    
    private lazy var imgView: UIImageView = {
        let view = UIImageView()
        view.layer.cornerRadius = 5.0
        view.layer.masksToBounds = true
        return view
    }()
    
    private lazy var textLabel: UILabel = {
        let label = UILabel()
        label.textColor = .wmc_grayH2_323233
        label.textAlignment = .center
        label.font = 14.wmc_font
        return label
    }()
    
    func bindModel(_ model: WmcWatermarkDetailModel, isSelected: Bool) {
        textLabel.text = model.name
        imgView.kf.setImage(with: URL(string: model.templateImg))
        
        contentView.layer.borderColor = isSelected ? UIColor.wmc_blue_5290FD.cgColor : UIColor.clear.cgColor
    }
}
